www.gusucode.com > 超声波测量以及形成图像 对相关信号进行模拟仿真 > 超声波测量以及形成图像 对相关信号进行模拟仿真/digital holograpy/dh/mifilter_window.m
function varargout = mifilter_window(varargin) % MIFILTER_WINDOW M-file for mifilter_window.fig % MIFILTER_WINDOW, by itself, creates a new MIFILTER_WINDOW or raises the existing % singleton*. % % H = MIFILTER_WINDOW returns the handle to a new MIFILTER_WINDOW or the handle to % the existing singleton*. % % MIFILTER_WINDOW('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MIFILTER_WINDOW.M with the given input arguments. % % MIFILTER_WINDOW('Property','Value',...) creates a new MIFILTER_WINDOW or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before mifilter_window_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to mifilter_window_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help mifilter_window % Last Modified by GUIDE v2.5 27-Aug-2007 11:44:15 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @mifilter_window_OpeningFcn, ... 'gui_OutputFcn', @mifilter_window_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before mifilter_window is made visible. function mifilter_window_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to mifilter_window (see VARARGIN) set(handles.lbox,'String',cell(1,0),'value',1); axes(handles.prev_axes) imagesc(ones(256)),colormap(gray); %axis equal tight; handles.ms=[2,2]; handles.phase=[]; if nargin > 4 for n=1:2:length(varargin) if strcmpi(varargin{n},'phasemaps') handles.phase=varargin{n+1}; if ~isempty(handles.phase) set(handles.lbox,'string',sort(fieldnames(handles.phase))) end end end end % Choose default command line output for mifilter_window handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes mifilter_window wait for user response (see UIRESUME) uiwait(handles.mifilter_window); % --- Outputs from this function are returned to the command line. function varargout = mifilter_window_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure if isempty(findobj('type','figure','tag','mifilter_window')) varargout{1}=[]; return end if strcmp(get(handles.done_button,'enable'),'off') varargout{1}=handles.phase; else varargout{1}=[]; end delete(handles.mifilter_window) % --- Executes during object creation, after setting all properties. function lbox_CreateFcn(hObject, eventdata, handles) % hObject handle to lbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in lbox. function lbox_Callback(hObject, eventdata, handles) % hObject handle to lbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns lbox contents as cell array % contents{get(hObject,'Value')} returns selected item from lbox if strcmp(get(handles.mifilter_window,'SelectionType'),'open') prev_button_Callback(handles.prev_button, [], handles); end % --- Executes during object creation, after setting all properties. function ms_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to ms_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function ms_edit_Callback(hObject, eventdata, handles) % hObject handle to ms_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of ms_edit as text % str2double(get(hObject,'String')) returns contents of ms_edit as a double handles.ms=round(abs(str2num(get(hObject,'string')))); if length(handles.ms)==1 handles.ms=[handles.ms,handles.ms]; end if isempty(handles.ms) || ~isequal(size(handles.ms),[1,2]) handles.ms=[1,1]; end handles.ms(handles.ms==0)=1; set(hObject,'string',['[',num2str(handles.ms(1)),',',num2str(handles.ms(2)),']']); guidata(hObject,handles) % --- Executes on button press in selected_radio. function selected_radio_Callback(hObject, eventdata, handles) % hObject handle to selected_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of selected_radio if get(handles.all_radio,'value')==get(handles.all_radio,'max') set(hObject,'value',get(hObject,'max')) set(handles.all_radio,'value',get(handles.all_radio,'min')) else set(hObject,'value',get(hObject,'max')) end % --- Executes on button press in all_radio. function all_radio_Callback(hObject, eventdata, handles) % hObject handle to all_radio (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of all_radio if get(handles.selected_radio,'value')==get(handles.selected_radio,'max') set(hObject,'value',get(hObject,'max')) set(handles.selected_radio,'value',get(handles.selected_radio,'min')) else set(hObject,'value',get(hObject,'max')) end % --- Executes on button press in done_button. function done_button_Callback(hObject, eventdata, handles) % hObject handle to done_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if isequal(get(handles.mifilter_window, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME set(hObject,'enable','off') uiresume(handles.mifilter_window); else % The GUI is no longer waiting, just close it delete(handles.mifilter_window); end % --- Executes when user attempts to close mifilter_window. function mifilter_window_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to mifilter_window (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: delete(hObject) closes the figure if isequal(get(handles.mifilter_window, 'waitstatus'), 'waiting') % The GUI is still in UIWAIT, us UIRESUME uiresume(handles.mifilter_window); else % The GUI is no longer waiting, just close it delete(handles.mifilter_window); end % --- Executes on button press in prev_button. function prev_button_Callback(hObject, eventdata, handles) % hObject handle to prev_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) items=get(handles.lbox,'string'); index=get(handles.lbox,'value'); if isempty(items) || length(index)>1 return end axes(handles.prev_axes) [vx,vy]=opticimage(handles.phase(2).(items{index}).MN2,handles.phase(2).(items{index}).dxy2(1),... handles.phase(2).(items{index}).dxy2(2),handles.phase(2).(items{index}).center); imagesc(vx,vy,handles.phase(1).(items{index}),[-pi,pi]);colormap(gray);axis xy image; % --- Executes on button press in filter_button. function filter_button_Callback(hObject, eventdata, handles) % hObject handle to filter_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) items=get(handles.lbox,'string'); if isempty(items) || isequal(handles.ms,[1,1]) return end if get(handles.selected_radio,'value')==get(handles.selected_radio,'max') index=get(handles.lbox,'value'); items=items(index); end N=length(items); if N>1 h=waitbar(0,'Calculating...','Name','Please wait'); end for n=1:N handles.phase(1).(items{n})=MIPfilter(handles.phase(1).(items{n}),... handles.phase(3).(items{n}).weight,handles.ms); if N>1 waitbar(n/N,h); end end if N>1 close(h); end guidata(hObject,handles) prev_button_Callback(handles.prev_button, [], handles);